﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Basmus.Tests
{
    public static class CollectionAssertHelper
    {
        public static void AreEqual(IEnumerable expected, IEnumerable actual)
        {
            if ((expected != null && actual == null) || (expected == null && actual != null))
                Assert.Fail();
            if (expected != null)
            {
                var expectedEnumerator = expected.GetEnumerator();
                var actualEnumerator = actual.GetEnumerator();
                var movenext = true;
                while (movenext)
                {
                    var expectedMoveNext = expectedEnumerator.MoveNext();
                    var actualMoveNext = actualEnumerator.MoveNext();
                    movenext = expectedMoveNext && actualMoveNext;
                    Assert.AreEqual(expectedMoveNext, actualMoveNext);
                    if (movenext)
                    {
                        Assert.AreEqual(expectedEnumerator.Current, actualEnumerator.Current);
                    }
                }
            }
            
        }
    }
}
